﻿Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.Data.SqlClient

' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class eHMS
    Inherits System.Web.Services.WebService
    Dim connect As New Connection()

    <WebMethod()> _
    Public Function PackageDetail(ItemCode As String) As DataSet
        Try
            Dim str As String
            str = "select T0.Quantity PAX, T1.ItemCode,T1.ItemName, T0.Price, CASE when T1.U_ItemSource='ROOM' then '1' else '0' end IsRoom, '' ItemGroup,T0.Warehouse OutletCode from ITT1 T0 join OITM T1 on T0.Code=T1.Itemcode  where T0.Father='" & ItemCode & "' order by Quantity"
            Dim dt As DataSet
            Dim connect As New Connection()
            connect.setDB("")
            dt = connect.ObjectGetAll_Query_SAP(str)
            Return dt
        Catch ex As Exception
            Return Nothing
        End Try
    End Function


    <WebMethod()> _
    Public Function PackageSelection(ItemCode As String, CardCode As String, _
                                 Quantity As Double, DocDate As Date, GroupCode As Integer) As DataSet
        Return GetPackageList(ItemCode, CardCode, Quantity, DocDate, GroupCode)
    End Function
    Public Function GetPackageList(ItemCode As String, CardCode As String, _
                                 Quantity As Double, DocDate As Date, GroupCode As Integer) As DataSet
        Try
            Dim str As String
            str = "exec sp_AI_PackageSelection '" & ItemCode & "'," & CStr(GroupCode) & ",'" & CStr(CardCode) & "'," & CStr(Quantity) & ",'" & DocDate.ToString("yyyy-MM-dd") & "'"
            Dim dt As DataSet
            Dim connect As New Connection()
            connect.setDB("")
            dt = connect.ObjectGetAll_Query_SAP(str)
            Return dt
        Catch ex As Exception
            Return Nothing
        End Try
    End Function
    <WebMethod()> _
    Public Function AddonSelection(CardCode As String, DocDate As Date, GroupCode As Integer) As DataSet
        Return GetAddonList(CardCode, DocDate, GroupCode)
    End Function
    Public Function GetAddonList(CardCode As String, DocDate As Date, GroupCode As Integer) As DataSet
        Try
            Dim str As String
            str = "exec sp_AI_AddonSelection " & CStr(GroupCode) & ",'" & CStr(CardCode) + "','" & DocDate.ToString("yyyy-MM-dd") & "'"
            Dim dt As DataSet
            Dim connect As New Connection()
            connect.setDB("")
            dt = connect.ObjectGetAll_Query_SAP(str)
            Return dt
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    <WebMethod()> _
    Public Function PackageMaster() As DataSet
        Return RunQuery("exec sp_AI_PackageMaster")
    End Function
    <WebMethod()> _
    Public Function AddonMaster() As DataSet
        Return RunQuery("exec sp_AI_AddonMaster")
    End Function
    <WebMethod()> _
    Public Function RoomTypeMaster() As DataSet
        Return RunQuery("exec sp_AI_RoomTypeMaster")
    End Function
    <WebMethod()> _
    Public Function MeetingRoomTypeMaster() As DataSet
        Return RunQuery("exec sp_AI_MeetingRoomTypeMaster")
    End Function
    <WebMethod()> _
    Public Function CorporateMaster() As DataSet
        Return RunQuery("Select CardCode, CardName,GroupName from OCRD T0 join OCRG T1 on T0.GroupCode=T1.GroupCode where T0.CardType='C' and T1.GroupName like '%Corporate%'")
    End Function
    <WebMethod()> _
    Public Function TravelAgentMaster() As DataSet
        Return RunQuery("Select CardCode, CardName,GroupName from OCRD T0 join OCRG T1 on T0.GroupCode=T1.GroupCode where T0.CardType='C' and T1.GroupName like '%Travel Agent%'")
    End Function
    <WebMethod()> _
    Public Function AgencyMaster() As DataSet
        Return RunQuery("Select CardCode, CardName,GroupName from OCRD T0 join OCRG T1 on T0.GroupCode=T1.GroupCode where T0.CardType='C' and T1.GroupName like '%Agency%'")
    End Function
    Public Function RunQuery(str As String) As DataSet
        Try
            Dim dt As DataSet
            Dim connect As New Connection()
            connect.setDB("")
            dt = connect.ObjectGetAll_Query_SAP(str)
            Return dt
        Catch ex As Exception
            Return Nothing
        End Try
    End Function

    
    
End Class